package com.iyundao.io.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.iyundao.io.model.RoleDept;
import org.springframework.stereotype.Repository;


@Repository
public class RoleDeptSqlProvider {

    public String insertSelective(RoleDept record) {
        BEGIN();
        INSERT_INTO("role_dept");
        
        if (record.getSid() != null) {
            VALUES("sid", "#{sid,jdbcType=CHAR}");
        }
        
        if (record.getRid() != null) {
            VALUES("rid", "#{rid,jdbcType=CHAR}");
        }
        
        if (record.getDid() != null) {
            VALUES("did", "#{did,jdbcType=CHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(RoleDept record) {
        BEGIN();
        UPDATE("role_dept");
        
        if (record.getRid() != null) {
            SET("rid = #{rid,jdbcType=CHAR}");
        }
        
        if (record.getDid() != null) {
            SET("did = #{did,jdbcType=CHAR}");
        }
        
        WHERE("sid = #{sid,jdbcType=CHAR}");
        
        return SQL();
    }
}